<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="chenxing-technology">
    <meta name="keyword" content="">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/resources/img/favicon.ico">
    <title>樱桃管理-农户录入</title>
    <!-- Bootstrap CSS -->    
    <link href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css" rel="stylesheet">
    <!-- bootstrap theme -->
    <link href="<%=request.getContextPath()%>/resources/css/bootstrap-theme.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/resources/css/elegant-icons-style.css" rel="stylesheet" />
    <link href="<%=request.getContextPath()%>/resources/css/style.css" rel="stylesheet">
     <script src="<%=request.getContextPath()%>/resources/js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    
  </head>

  <body>
  	<div class="background">
  		
  	</div>
  <!-- container section start -->
  <section id="container" class="">
         
      <jsp:include page="heads.jsp" />

      <!--sidebar start-->
      <aside>
          <div id="sidebar"  class="nav-collapse ">
              <!-- sidebar menu start-->
              <ul class="sidebar-menu">                
                  <li class="sub-menu">
                      <a href="javascript:;" class="">
                          <span>单据信息</span>
                          <span class="menu-arrow"></span>
                      </a>
                      <ul name="sub" class="sub">
                          <li><a class="" href="${ctx }/summary/summaryAdd">单据录入</a></li>                          
                          <li><a class="" href="${ctx }/summary/selectSum?pageNow=1">单据录入汇总</a></li>
                          <li><a class="" href="${ctx }/getTable/addGet">单据领取</a></li>
                          <li><a class="" href="${ctx }/getTable/showGet?pageNow=1">单据领取汇总</a></li>
                      </ul>
                  </li> 
				          <li class="sub-menu">
                      <a href="javascript:;" class="">
                          <span>商户录入</span>
                          
                      </a>
                      <ul name="sub" class="sub">
                          <li><a class="" href="${ctx }/meentry/addMeJsp">商户录入</a></li>                          
                          <li><a class="" href="${ctx }/meentry/showMeenAll?pageNow=1">商户录入汇总</a></li>
                          <li><a class="" href="${ctx }/meentry/orderlist">订单信息</a></li>
                      </ul>
                  </li>       
                  <li class="sub-menu open">
                      <a href="${ctx }/meentry/farmerJsp" class="">
                          <span>农户录入</span>
                          <span class="menu-arrow"></span>
                      </a>
                  </li>
                  <li class="sub-menu">
                      <a class="" href="${ctx }/meentry/settlement?pageNow=1">
                          <span>结算信息</span>
                          <span class="menu-arrow"></span>
                      </a>
                  </li>
                 
              </ul>
               <div class="add-button text-center">
              	<a href="${ctx }/user/addUserJsp">添加账号</a>
              </div>
              <!-- sidebar menu end-->
          </div>
      </aside>
      <!--sidebar end-->
      
       <!--main content start-->
      <section id="main-content">
          <section class="wrapper">            
              <!--overview start-->
			        <div class="row form-input">
			        	  <div class="img-ico div-center text-center">
                      <img src="<%=request.getContextPath()%>/resources/img/receive.png"/>
                      <p class="title">单据领取</p>
                  </div> 
                  <div class="col-md-4 div-center input-content1">
                  			
                      <section class="panel">
                        <div class="panel-body">
                        	 <div class="form-group ">
                              <label class="control-label col-sm-2">单据个数：</label>
                              <div class="col-sm-3 col-left">
                                  <input type="text" value="" class="cp1 form-control" id="cp1">
                              </div>
                              <input type="button" name="getvalue" id="getvalue" value="确定" />
                           </div> 
                  	<form class="form-validate form-horizontal" id="feedback_form" method="post" action="${ctx }/meentry/settlementStatus" >                  	
                           <div id="danju">
                           	
                           </div>
                        </div>
                      </section>
                      <div class="form-group">
                        <div class="col-lg-12 text-center">
                        	<button class="btn btn-default" type="button" onClick="history.back()">取消</button>
                          <button class="btn btn-primary" type="submit">结算</button>                   
                        </div>
                      </div>
                   </form>
                  </div>                  
              </div>
          </section>
      <!--main content end-->
     </section>
     <script type="text/javascript">
     	$(function(){
     		var btn=$("#getvalue");
     		var value1="";
     		var k = 1;
        btn.click(function(){
        	var z = "";
        	value1=document.getElementById("cp1").value;
        	 for(i=0;i<value1;i++){
        	 	k=i+1;
	     		var a="<div class='form-group'><label class='control-label col-sm-2'>单据号：</label><div class='col-sm-3'><input type='text' id='djh"+k+"' name='djh"+k+"' value='' class='cp1 form-control'></div><label class='control-label col-sm-1'>金额：</label><div class='col-sm-2'><input type='number' id='je"+k+"' name='je"+k+"' value='' min='0.0' step='0.1' placeholder='请输入金额' onmouseout='js("+k+")' class='cp1 form-control'></div><label class='control-label col-sm-1'>手续费：</label><div class='col-sm-1'><input type='text' id='sxf"+k+"' name='sxf"+k+"' value='' class='cp1 form-control'></div><label class='control-label col-sm-1 ' id='ts"+k+"' style='color:red;'></label></div>"
        		z+=a;
        	  }
//        document.getElementById("danju").innerHTML = z;
          $('#danju').html(z);
        }) 
       
        
     	})
     	
     	
     $(function() {
     var menu = $(".sidebar-menu .sub-menu")
     menu.click(function() {
         i = $(this).index();
         $(this).addClass("open").siblings().removeClass("open");
         $(this).children(".sub").addClass("current");
         $(this).siblings().children(".sub").removeClass("current");
     })
     })
     /* 计算手续费以及总金额  */
     function js(k){
     	var djh = $("#djh"+k).attr("value");
     	var je = $("#je"+k).attr("value");
     	var sxfcs = 0.05;
     	var sxf = je*sxfcs;
     	
     	if(djh!="" && je!=""){
     		$("#sxf"+k).attr("value",sxf.toFixed(2));
     		/* 数据查询验证 */
  		  var   boo='';
  			$.ajax({
  		                url : '<%=basePath%>meentry/farmerTest',
  		                data:{"djh":djh,"je": je},
  		                type : 'post',
  		                dataType : 'json',
  		                async : false,
  		                success : function(data) {
  		                       if(data!=null){
  		                          if(data.result=='1'){
  		                        	  var djh = $("#ts"+k).text("");
  		                          		boo='a';
  		                          		return  true;
  		                          } 
  		                           if(data.result=='0'){
  		                        	   var djh = $("#ts"+k).text("金额错误");
  		                           		boo='b';
  		                          		return  false;
  		                          } 
  		                       }                                                    
  		                }
  		         })
  		         if(boo=='a'){
  		        	 return  false;
  		         }
     	}
     	
     	
     }
     	
     	
     </script>
  </body>
</html>
